{% extends "mapp/base.html" %}

{% block header %} MAPP analysis result {% endblock %}

{% block content %}
<section id="result">
	<h3>ID:</h3>
	<p>{{ query_id }}</p>
	{% if query %}
		<h3>Date:</h3>
		<p>{{ query.date }}</p>
		<h3>Detail:</h3>
		<p>Go to <a href="{% url 'mapp:detail' query_id %}">detail</a></p>
		<h3>Download</h3>
		<ul>
		<li><a style="font-weight: bold; font-size: medium" href="{% url 'mapp:download' query_id 'result' %}">Result csv</a></li>
		<li><a href="{% url 'mapp:download' query_id 'seqs' %}">Unaligned sequences</a></li>
		<li><a href="{% url 'mapp:download' query_id 'stats' %}">Sequences statistics</a></li>
		<li><a href="{% url 'mapp:download' query_id 'msa' %}">Multiple sequence alignment</a></li>
		<li><a href="{% url 'mapp:download' query_id 'tree' %}">Phylogenetic tree</a></li>
		<li><a href="{% url 'mapp:download' query_id 'mapp' %}">Original mapp analysis for whole protein</a></li>
		</ul>
		
		<div class="pagination">
		    <span class="step-links">
		        {% if results.has_previous %}
		            <a href="?page={{ results.previous_page_number }}">previous</a>
		        {% endif %}
		
		        <span class="current">
		            Page {{ results.number }} of {{ results.paginator.num_pages }}.
		        </span>
		
		        {% if results.has_next %}
		            <a href="?page={{ results.next_page_number }}">next</a>
		        {% endif %}
		    </span>
		</div>
		<table>
		<thead>
			<tr>
				<th>Mutations</th><th>Prediction</th><th>P&#8209;value</th><th style="width: 180px">Occurrence of amino acids in alignment</th>
			</tr>
		</thead>
		<tbody>
		{% for result in results %}
			<tr>
				<td>{{ result.mutation }}</td>
				{% if result.state == "correct" %}
					<td>{{ result.prediction }}</td>
					<td>{{ result.pvalue }}</td>
					<td>{{ result.alignment }} </td>
				{% elif result.state == "incorrect letter" %}
					<td> wrong letter </td>
					<td></td>
					<td></td>
				{% elif result.state == "not predicted" %}
					<td> N/A </td>
					<td> N/A </td>
					<td>{{ result.alignment }}</td>
				{% else %}
					<td>wrong state - error occured</td>
					<td></td>
					<td></td>
				{% endif %}
			</tr>
		{% endfor %}
		</tbody>
		</table>
		<div class="pagination">
		    <span class="step-links">
		        {% if results.has_previous %}
		            <a href="?page={{ results.previous_page_number }}">previous</a>
		        {% endif %}
		
		        <span class="current">
		            Page {{ results.number }} of {{ results.paginator.num_pages }}.
		        </span>
		
		        {% if results.has_next %}
		            <a href="?page={{ results.next_page_number }}">next</a>
		        {% endif %}
		    </span>
		</div>
	{% else %}
		<table><tr><td>Analysis with this id isn't completed or doesn't exist</td></tr></table>
	{% endif %}
	
</section>
{% endblock %}
